<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
	
		 <link rel="stylesheet" href="../../plugins/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
<!--  <link rel="stylesheet" href="../../https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
-->  <!-- Theme style -->
  <link rel="stylesheet" href="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
  

  <style>
  	td{
  	 text-align: center;	
  		
  	}
  	
  </style>
  
		<title></title>
	</head>
	<body>
		<button type="button" id="xzrk" disabled="disabled" onclick="rukuall()" class="btn btn-lg btn-default">选中入库</button>
		<button type="button" class="btn btn-lg btn-primary">查看装车单</button>
           <button type="button" class="btn btn-lg btn-info">查看中转单</button>
		   <div class="card card-primary card-outline">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="fa fa-bar-chart-o"></i>
                                    显示区
                </h3>
                <div class="card-tools">
                  <button type="button" class="btn btn-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                  </button>
                  <button type="button" class="btn btn-tool" data-widget="remove"><i class="fa fa-times"></i>
                  </button>
                </div>
              </div>
              <div class="card-body">
              	 <select id="qu" onchange='choosequ()'>
		  	<option value="">区</option>
		  </select>
		   <select id="pai" onchange='choosepai()'>
		  	<option value="">排</option>

		  </select> 
		   <select id="jia" onchange='choosejia()'>
		  	<option value="">架</option>

		  </select>
		   <select id="wei">
		  	<option value="">位</option>

		  </select>		
		  <p></p>
              	  <table id="tab" border="2px" align="center" width="100%" class="table table-bordered table-striped" border="2px">
     	<tr>
        <td><input type="checkbox" name="selectall" />选中入库</td>
     	<td>编号</td>
     	<td>出发日期</td>
     	<td>目的地</td>
     	<td>总价</td>
     	<td>寄件人</td>
     	<td>收件人</td>
     	<td>类型</td>
     	<td>是否可被签收？</td>
     	<td>是否被审核</td>
        <td>是否被签收</td>
         <td>操作</td>
     	</tr>	
     </table> 
     <div align="center">
                <ul id="page" class="pagination pagination-lg m-0 float-right">
                  
                 
                </ul>
              </div>
                <div id="donut-chart" style="height: 300px;"></div>
                
              </div>
                           <!-- /.card-body-->
            </div>
		  
		              

     
     <script src="../../plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Morris.js charts -->

<!-- Bootstrap WYSIHTML5 -->
<script src="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<!-- AdminLTE App -->

<script src="../../dist/js/adminlte.js"></script>
	<script src="../../js/login.js"></script>
	<script src="../../js/jquery.cookie.js"></script>

	</body>

	<script>
		var zz=[];
		var zc=[];
		 zcd();
		function previous(pageNum,totalPage,hah){
			if(hah==0){
				urladdr="http://localhost:8072/selectzc"
			}else if(hah==1){
				urladdr="http://localhost:8072/selectzz"
			}
			
			if(pageNum<=1){
				pageNum=1;
			}
			$("#page").empty();
			 $("#tab tr:gt(0)").empty();
             $("#tab tr").not(':eq(0)').empty();

		$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: urladdr,
				 xhrFields:{withCredent: true},
				 data:{"sid":$.cookie("sid"),"pageNum":pageNum},
	             crossDomain: true,
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
					
					
				$("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+")' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 

				 	$.each(data.list, function(i,d){
				 		
					  $("#tab").append("<tr> <input type='hidden' name='sasid' value='"+d.sendasingle.sasid+"'/><td><input type='checkbox' name='storage' /><td>"+d.sendasingle.sasid+"</td></td><td>"+d.sendasingle.starting+"</td><td>"+d.sendasingle.cargoinformation+"</td><td>"+d.sendasingle.totalvalue+"</td><td>"+d.sendasingle.senderinformation+"</td><td>"+d.sendasingle.consigneeinformation+"</td><td>"+d.sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+d.sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+d.sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+d.sendasingle.issignforit+"<span></td></tr>")
					 });
				 $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+")'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 

					 
					 
					 //请求成功处理，和本地回调完全一样
					 
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
		
			
			
		}
		
		function next(pageNum,totalPage,hah){
			 $("#page").empty();
			 $("#tab tr:gt(0)").empty();
             $("#tab tr").not(':eq(0)').empty();
             if(hah==0){
				urladdr="http://localhost:8072/selectzc"
			}else if(hah==1){
				urladdr="http://localhost:8072/selectzz"
			}
			
             if(pageNum>=totalPage){
             	pageNum=totalPage;
             }
             
			$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: urladdr,
				 xhrFields:{withCredent: true},
				 data:{"sid":$.cookie("sid"),"pageNum":pageNum},
	             crossDomain: true,
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
					$("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+")' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 
				 	$.each(data.list, function(i,d){
				 		
					  $("#tab").append("<tr> <input type='hidden' name='sasid' value='"+d.sendasingle.sasid+"'/><td><input type='checkbox' name='storage' /><td>"+d.sendasingle.sasid+"</td></td><td>"+d.sendasingle.starting+"</td><td>"+d.sendasingle.cargoinformation+"</td><td>"+d.sendasingle.totalvalue+"</td><td>"+d.sendasingle.senderinformation+"</td><td>"+d.sendasingle.consigneeinformation+"</td><td>"+d.sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+d.sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+d.sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+d.sendasingle.issignforit+"<span></td></tr>")
					 });
					 	 $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+")'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 

					 
					 
					 //请求成功处理，和本地回调完全一样
					 
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
		
			
		}
		
		
		function choosequ(){
			$("#pai").empty();
		
			 $.ajax({
           	 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8072/selectpai",
				 data:{"region":$("#qu").val(),"sid":$.cookie("sid")},
				 dataType: "json", //跨域json请求一定是jsonp
	             xhrFields:{withCredent: true},
	             crossDomain: true,
				 beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
				 	$.each(data, function(i,d) {    
                      $("#pai").append("<option>"+data[i].rank+"</option>")				 		
					 });
					 //请求成功处理，和本地回调完全一样		
				},		
				 error: function() {
					 //请求出错处理					
				}
           	
           	
           })
			
			
		}
		
		function choosepai(){
			$("#jia").empty();
				 $.ajax({
           	 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8072/selectjia",
				 data:{"rank":$("#pai").val(),"region":$("#qu").val(),"sid":$.cookie("sid")},
				 dataType: "json", //跨域json请求一定是jsonp
	             xhrFields:{withCredent: true},
	             crossDomain: true,
				 beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
				 	$.each(data, function(i,d) {    
                      $("#jia").append("<option>"+data[i].frame+"</option>")				 		

					 });
					 //请求成功处理，和本地回调完全一样
			
				},		
				 error: function() {
					 //请求出错处理
					
				}
           	
           	
           })
			
			
			
		}
		
			function choosejia(){
				$("#wei").empty();
				 $.ajax({
           	 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8072/selectwei",
				 data:{"frame":$("#jia").val(),"region":$("#qu").val(),"rank":$("#pai").val(),"sid":$.cookie("sid")},
				 dataType: "json", //跨域json请求一定是jsonp
	             xhrFields:{withCredent: true},
	             crossDomain: true,
				 beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
				 	$.each(data, function(i,d) {    
                      $("#wei").append("<option>"+data[i].place+"</option>")				 		

					 });
					 //请求成功处理，和本地回调完全一样
			
				},		
				 error: function() {
					 //请求出错处理
					
				}
           	
           	
           })
			
			
			
		}
		
		$(function(){ 
			
           $.ajax({
           	 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8072/selectqu",
				 dataType: "json", //跨域json请求一定是jsonp
				 data:{"sid":$.cookie("sid")},
	             xhrFields:{withCredent: true},
	             crossDomain: true,
				 beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
				 	$.each(data, function(i,d) {    
                      $("#qu").append("<option>"+data[i].region+"</option>")				 		

					 });
					 //请求成功处理，和本地回调完全一样
			
				},		
				 error: function() {
					 //请求出错处理
					
				}
           	
           	
           })
           
			
			
	/*查询未入库所有*/
	$("button:contains('装车')").on("click",function(){
          zcd();

		
	 });
	     
	 $("button:contains('中转')").on("click",function(){
	 	     $("#page").empty();
	         $("#tab tr:gt(0)").empty();
             $("#tab tr").not(':eq(0)').empty()
	 
		$.ajax({
				type: "post", //请求方式
				async: true, //是否异步
				url: "http://localhost:8072/selectzz",
				xhrFields:{withCredent: true},
				data:{"sid":$.cookie("sid")},
	            crossDomain: true,
				dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
		
				 	
					$("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+",1)' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 
				 	$.each(data.list, function(i,d){
				 		zz[i]=d;
					  $("#tab").append("<tr> <input type='hidden' name='sasid' value='"+d.sendasingle.sasid+"'/><td><input type='checkbox' name='storage' /><td>"+d.sendasingle.sasid+"</td></td><td>"+d.sendasingle.starting+"</td><td>"+d.sendasingle.cargoinformation+"</td><td>"+d.sendasingle.totalvalue+"</td><td>"+d.sendasingle.senderinformation+"</td><td>"+d.sendasingle.consigneeinformation+"</td><td>"+d.sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+d.sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+d.sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+d.sendasingle.issignforit+"<span></td><td><button class='btn btn-success' onclick='rukuone("+i+",0)'>入库</button></td></tr>")
					 });
					 //请求成功处理，和本地回调完全一样
					 $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+",1)'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
	}); 
	 
	 
	 });
	 
	 
   
	
	/*入库生成入库单*/
      $('input[name="selectall"]').click(function(){ 
  
      	   
             if($(this).is(':checked')){  
             	$("#xzrk").attr("disabled",false);
                $('input[name="storage"]').each(function(){  
                    //此处如果用attr，会出现第三次失效的情况  
                    $(this).prop("checked",true);  
                });  
        }else{  
        	$("#xzrk").attr("disabled",true);
            $('input[name="storage"]').each(function(){  
                    $(this).prop("checked",false);  
                });  
                //$(this).removeAttr("checked");  
        } 
    });   
    
    

   

	}); 
	      

	 
	   function rukuall(){
      	alert(123);
      	var  arr=[];
      	var i=0;
      	 var check=$("input[name='storage']:checked");//选中的复选框
	     check.each(function(){
		 var row=$(this).parent("td").parent("tr");
	 	 var sasid=row.children().eq(0).val();//注意html()和val()
		 var cargoinformation=row.children().eq(4).text();
		
	
		 arr[i]=sasid;
		 
		 i++;
	     });
       	
       	
       	$.ajax({
       		type: "post", //请求方式
				async: true, //是否异步
				url: "http://localhost:8072/rukuall",
				xhrFields:{withCredent: true},
				traditional:true,
				data:{"sid":$.cookie("sid"),"arr":arr},
	            crossDomain: true,
				dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
					if(data==1){
						alert("库存位置不足");
					}else{
					alert("已然ojbk");
					window.location.reload();
					}
				}
       		
       		
       		
       		
       	})
       	
       	
       	
      }
	   
	   
	   function  zcd(){
	   	    $("#page").empty();
		 	 $("#tab tr:gt(0)").empty();
             $("#tab tr").not(':eq(0)').empty();
	   	$.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 url: "http://localhost:8072/selectzc",
				 xhrFields:{withCredent: true},
				 data:{"sid":$.cookie("sid")},
	             crossDomain: true,
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
					
					
					$("#page").append("<li class='page-item' onclick='previous("+(data.pageNum-1)+","+data.totalPage+",0)' ><a class='page-link float-left' href='#'>&laquo;</a></li>"); 
				 	$.each(data.list, function(i,d){
				 		zc[i]=d;
				 		
					  $("#tab").append("<tr> <input type='hidden' name='sasid' value='"+d.sendasingle.sasid+"'/><td><input type='checkbox' name='storage' /><td>"+d.sendasingle.sasid+"</td></td><td>"+d.sendasingle.starting+"</td><td>"+d.sendasingle.cargoinformation+"</td><td>"+d.sendasingle.totalvalue+"</td><td>"+d.sendasingle.senderinformation+"</td><td>"+d.sendasingle.consigneeinformation+"</td><td>"+d.sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+d.sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+d.sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+d.sendasingle.issignforit+"<span></td><td><button class='btn btn-success' onclick='rukuone("+i+",1)'>入库</button></td></tr>")
					 });
					 
					 
					 
					 //请求成功处理，和本地回调完全一样
					 $("#page").append("<li class='page-item' onclick='next("+(data.pageNum+1)+","+data.totalPage+",0)'><a class='page-link float-right' href='#'>&raquo;</a></li>"); 
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
	   	
	   }
      
	 
	
	
	    function rukuone(i,cut){
         
    	if($("#qu").val()=="" || $("#pai").val()=="" || $("#jia").val()=="" || $("#wei").val()==""){
    		alert("请写区排架位");
    		throw SyntaxError();
    	}
    	
    		 var sasid;
    	     var cargoinformation;
    	     
    	if(cut==0){
    		sasid=zz[i].sendasingle.sasid;
    		cargoinformation=zz[i].sendasingle.cargoinformation;
    				
    	}else{
    		sasid=zc[i].sendasingle.sasid;
    		cargoinformation=zc[i].sendasingle.cargoinformation;
    		
    		
    	}
    	
    	  
        var now = new Date();  
          
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
          
        var hh = now.getHours();            //时  
        var mm = now.getMinutes();          //分  
        var ss = now.getSeconds();           //秒  
          
        var clock = year + "-";  
          
        if(month < 10)  
            clock += "0";  
          
        clock += month + "-";  
          
        if(day < 10)  
            clock += "0";  
              
        clock += day + " ";  
          
        if(hh < 10)  
            clock += "0";  
              
        clock += hh + ":";  
        if (mm < 10) clock += '0';   
        clock += mm + ":";   
           
        if (ss < 10) clock += '0';   
        clock += ss;   
     
    
    
    
	 
	   $.ajax({
				 type: "post", //请求方式
				 async: true, //是否异步
				 xhrFields:{withCredent: true},
	             crossDomain: true,
				 url: "http://localhost:8072/Addstorage",
				  traditional: true,
				 data:{"sasid":sasid,"Inbounddate":clock,"scargoinformation":cargoinformation,
				        "region":$("#qu").val(),"rank":$("#pai").val(),"frame":$("#jia").val(),"place":$("#wei").val() },
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
			
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
					alert("你干嘛呢");
				   window.location.reload();
					 //请求成功处理，和本地回调完全一样				
				},		
				 error: function() {
					 //请求出错处理
					
				}
	});
    	
    	
    	
  
    };
	
	
	</script>
</html>
